<?php
declare (strict_types = 1);

namespace app\adminapi\model\system\organize;

use adminmatrix\server\app\model\BaseModel;
use think\model\relation\HasOne;

/**
 * @mixin \think\Model
 */
class AdminDepartment extends BaseModel
{


    #-------------------------------------------------------------------
    # 搜索器 search Attr
    #-------------------------------------------------------------------
    # 搜索部门名称
    public function searchNameAttr($query , $value , $data) {
        if (empty($value)) return '';
        $query->whereLike('name' ,"%{$value}%");
    }


    #-------------------------------------------------------------------
    # 关联表
    #-------------------------------------------------------------------

    # 关联组织表
    public function organization() : HasOne
    {
        return $this->hasOne(AdminOrganization::class , 'id' , 'organization_id');
    }
}
